import axios from '../AxiosConfig.js'

export const createUser = data => {
  return axios({
    method: 'put',
    url: '/api/users/' + data.username,
    data: data
  })
}

export const deleteUser = (username) => {
  return axios({
    method: 'delete',
    url: '/api/users/' + username,
  })
}

export const selectUser = (username) => {
  return axios({
    method: 'get',
    url: '/api/users/' + username
  })
}

export const listUser = (username) => {
  return axios({
    method: 'get',
    url: '/api/users',
    params: {
      "page": 1,
      "page_size": 500,
      "name": username,
      "use_regex": false,
      "pagination": true
    }
  })
}

export const listUserPermission = (username) => {
  return axios({
    method: 'get',
    url: '/api/users/' + username + "/permissions"
  })
}

export const listUserTopicPermission = (username) => {
  return axios({
    method: 'get',
    url: '/api/users/' + username + "/topic-permissions"
  })
}


